{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# ModelScope-Agent 多人聊天室示例\n",
    "\n",
    "克隆代码"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "cf477ff6c5b26a0b"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "!git clone https://github.com/modelscope/modelscope-agent"
   ],
   "metadata": {
    "collapsed": true
   },
   "id": "initial_id",
   "execution_count": 0
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "!cd modelscope-agent && pip install -r requirements.txt"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "f56ad3a5c2675562"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import os\n",
    "os.chdir('modelscope-agent/apps/multi_roles_chat_room')"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "b4ef68c9e5d9aa8"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('../../')"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "c893a695ac87a87e"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "\n",
    "# Dashscope API KEY\n",
    "print('请输入Dashscope API KEY，可以从这里获取: https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key')\n",
    "os.environ['DASHSCOPE_API_KEY'] = input()\n",
    "\n",
    "# Turn off pre-start ray's components on single machine \n",
    "os.environ['RAY_prestart_worker_first_driver'] = 'false'"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "58a9cb4f6b8259bb"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# make sure update the abs path of modelscope-agent\n",
    "! sed -i 's#demo.launch()#demo.launch(share=True)#g' app.py && export PYTHONPATH=$PYTHONPATH:/content/modelscope-agent && python app.py"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "8e88b7a78e8427d9"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
